//
//  JWGRKCcell.m
//  test
//
//  Created by 李彦宏 on 2018/3/15.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "JWGRKCcell.h"
#define black [UIColor blackColor]//字体颜色
#define FontSize [UIFont systemFontOfSize:14]
#import "Utility.h"
@implementation JWGRKCcell


//类方法快速创建cell
+(instancetype)cellwithTableview:(UITableView *)tableview{
    
    // 1.创建cell
    static NSString *ID = @"cell1";
    JWGRKCcell *cell = [tableview dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[JWGRKCcell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return  cell;
    
}
/**
 *  cell的初始化方法，一个cell只会调用一次
 *  一般在这里添加所有可能显示的子控件，以及子控件的一次性设置
 */
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //添加UI控件
        [self setUI];
    }
    return self;
}

-(void)setUI{
    UILabel *lb1=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 80, 40)];
    lb1.text=@"张老三》";
    lb1.textColor=black;
    lb1.numberOfLines=0;
    lb1.font=FontSize;
    lb1.textAlignment=NSTextAlignmentCenter;
    self.Sneme=lb1;
    [self.contentView addSubview:lb1];
    
    
    UILabel *lb3=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/4-10, 8, 50, 25)];
    lb3.text=@"60";
    lb3.textColor=black;
    lb3.font=FontSize;
    lb3.textAlignment=NSTextAlignmentCenter;
    self.KCtime=lb3;
    [self.contentView addSubview:lb3];
    
    UILabel *lb4=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-10, 8, 35, 25)];
    lb4.text=@"100";
    lb4.textColor=black;
    lb4.font=FontSize;
    lb4.textAlignment=NSTextAlignmentCenter;
    self.KCprice=lb4;
    [self.contentView addSubview:lb4];
    UILabel *lb5=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth*0.7-15, 8, 35, 25)];
    lb5.text=@"100";
    lb5.textColor=black;
    lb5.font=FontSize;
    lb5.textAlignment=NSTextAlignmentCenter;
    self.KCcombined=lb5;
    [self.contentView addSubview:lb5];
    UIButton *bt6=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-70, 8, 67, 25)];
    [bt6 setTitle:@"添加截图" forState:UIControlStateNormal];
    bt6.titleLabel.font=FontSize;
    [bt6 setTitleColor:black forState:UIControlStateNormal];
    [bt6 setBackgroundColor:dominantColor];
    bt6.layer.cornerRadius=4;
    bt6.showsTouchWhenHighlighted=YES;
    [bt6 addTarget:self action:@selector(AddbtnAction:) forControlEvents:UIControlEventTouchUpInside];
    self.KCcondPayBtn=bt6;
    [self.contentView addSubview:bt6];
    //分割线
    UILabel *lbF=[[UILabel alloc]initWithFrame:CGRectMake(0, 44, ScreenWidth, 1)];
    lbF.text=@"";
    lbF.backgroundColor=[UIColor lightGrayColor];
    [self.contentView addSubview:lbF];
    
    
}
//查看/提交按钮事件
-(void)AddbtnAction:(UIButton *)send{
    
    self.AddImageBlock();
}

-(void)setModel:(JWKCFeemodel *)model{
       _model=model;
    self.Sneme.text=_model.sname;
    self.KCprice.text=_model.sprice;
//上课时间显示
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];// 创建一个时间格式化对象
//    [dateFormatter setDateFormat:@"yyyy-MM-dd"]; //设定时间的格式
//    NSArray *p=[[Utility getDateStringWithTimeStr:_model.starttime] componentsSeparatedByString:@" "];
//    NSArray *p2=[[Utility getDateStringWithTimeStr:_model.endtime] componentsSeparatedByString:@" "];
//    //NSLog(@"分割后的字符串：%@",p[1]);
//    self.KCtime.text = [NSString stringWithFormat:@"%@\n%@-%@",p[0],p[1],p2[1]];
    
    double sc = ([_model.endtime doubleValue] - [_model.starttime doubleValue]);
    self.KCtime.text = [NSString stringWithFormat:@"%.f",sc/60];
    NSInteger price=[_model.sprice doubleValue];
    
    self.KCcombined.text=[NSString stringWithFormat:@"%.f",sc/3600*price];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
